import { request } from "@yaf/request";
import { toApi } from "@/service/proxyApi";
import { RespDataType, RequestDataType } from "./apiType";
export * from "./apiType";

const { get, del, postJSON, put } = request;

/**
 * 获取岗位分页列表
 */
export const getPostPageList = (params: { page: number, pageSize: number, postCode?: string, postName?: string, status?: string }) => {
  return get<PageList<RespDataType.PostItem>>(toApi("api/v1/system/post/list"), params);
}

/**
 * 新增岗位数据
 */
export const createPost = (params: RequestDataType.CreatePostItem) => {
  return postJSON(toApi("api/v1/system/post/add"), params);
}

/**
 * 获取岗位信息
 */
export const getPostInfo = (postId: number) => {
  return get<RequestDataType.CreatePostItem>(toApi("api/v1/system/post/get"), { postId });
}

/**
 * 更新岗位信息
 */
export const updatePostInfo = (params: RequestDataType.CreatePostItem) => {
  return put(toApi("api/v1/system/post/edit"), params);
}

/**
 * 删除岗位信息
 */
export const deletePostInfo = (postIdList: number[]) => {
  return del(toApi(`api/v1/system/post/delete?ids=${JSON.stringify(postIdList)}`));
}
